/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2022. All rights reserved.
 *
 */

/**
 * 定义c++支持的cpu架构
 *
 * @since 2022/2/25
 */
import { OhosLogger } from '../utils/log/ohos-logger.js';
const _log = OhosLogger.getLogger('CpuAbiEnum');

export enum CpuAbiEnum {
  ARM64_V8A = 'aarch64-linux-ohos',
  ARMEABI_V7A = 'arm-linux-ohos',
  X86_64 = 'x86_64-linux-ohos',
}

/**
 * 为CpuAbiEnum枚举类型附加方法
 *
 * @since 2022/2/25
 */
export namespace CpuAbiEnum {
  export const getCpuType = (type: string): CpuAbiEnum => {
    switch (type) {
      case 'arm64-v8a':
        return CpuAbiEnum.ARM64_V8A;
      case 'armeabi-v7a':
        return CpuAbiEnum.ARMEABI_V7A;
      case 'x86_64':
        return CpuAbiEnum.X86_64;
      default:
        _log.printErrorExit(
          'UNKNOWN_CPU_ABI',
          [type]
        );
        return CpuAbiEnum.ARM64_V8A;
    }
  };
}
